//
//  UserLoginName.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/10/13.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "UserLoginName.h"
#import <SAMKeychain.h>
@implementation UserLoginName


+(void)SaveLoginInfor:(UserLoginName*)model
{
    NSLog(@"%@",model.mj_keyValues);
    
     [USER_DEFAULT setObject:[model mj_keyValuesWithIgnoredKeys:@[@"loginPwd"]] forKey:@"TBUserName"];
 
     [SAMKeychain setPassword:model.loginPwd forService:model.loginType account:model.loginName];
}

+(NSDictionary*)GetLoginInfor
{
    NSMutableDictionary *UserDict=nil;
    
    NSDictionary*dict=  [USER_DEFAULT objectForKey:@"TBUserName"]!=nil?[USER_DEFAULT objectForKey:@"TBUserName"]:@{};
  
    if (dict.count!=0) {
        
        UserDict=[[NSMutableDictionary alloc]initWithDictionary:dict];
        
      NSString* pwd= [SAMKeychain passwordForService:dict[@"loginType"] account:dict[@"loginName"]];
        
        [UserDict setValue:pwd forKey:@"loginPwd"];
    }
    
    return UserDict;
}


@end
